/**
 * Copyright 2025 Huawei Technologies Co., Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_IMAGE_PYAV_FRAME_H_
#define MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_IMAGE_PYAV_FRAME_H_

extern "C" {
#include <libavutil/frame.h>
}

#include <memory>
#include <vector>

#include "minddata/dataset/core/pybind_support.h"
#include "minddata/dataset/util/status.h"

namespace mindspore::dataset {
namespace py = pybind11;

class Frame {
 public:
  Frame();

  ~Frame();

  virtual void SetTimeBase(AVRational *time_base);

  virtual int GetPTS();

  virtual AVFrame *GetAVFrame();

  virtual Status InitUserAttributes();

 protected:
  AVFrame *frame_;
  AVRational *time_base_;
};

class VideoFrame : public Frame {
 public:
  VideoFrame();
};

Status AllocVideoFrame(std::shared_ptr<Frame> *frame);

class AudioFrame : public Frame {
 public:
  AudioFrame();

  Status InitUserAttributes() override;

  std::vector<py::array> ToNumpy();

 private:
  AVChannelLayout layout_;
  AVSampleFormat format_;
};

Status AllocAudioFrame(std::shared_ptr<Frame> *frame);
}  // namespace mindspore::dataset
#endif  // MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_IMAGE_PYAV_FRAME_H_
